Skip to content

feat!: added final job statuses middleware handler on crud operations (MAPCO-9859)#56

Merged
CL-SHLOMIKONCHA merged 8 commits intomasterfrom
aborted-job-constraint
Feb 24, 2026
Merged

feat!: added final job statuses middleware handler on crud operations (MAPCO-9859)#56
CL-SHLOMIKONCHA merged 8 commits intomasterfrom
aborted-job-constraint

Conversation

@CL-SHLOMIKONCHA
Copy link
Contributor

@CL-SHLOMIKONCHA CL-SHLOMIKONCHA commented Feb 11, 2026

Added task creation condition for an aborted job

Question Answer
Bug fix
New feature
Breaking change
Deprecations
Documentation
Tests added
Chore

@CL-SHLOMIKONCHA CL-SHLOMIKONCHA changed the title fix: added tasks creation condition for aborted job status fix: added tasks creation condition for aborted job status (MAPCO-9859) Feb 11, 2026
@CL-SHLOMIKONCHA CL-SHLOMIKONCHA changed the title fix: added tasks creation condition for aborted job status (MAPCO-9859) feat!: added final job statuses middleware handler on crud operations (MAPCO-9859) Feb 15, 2026
const jobManager = container.resolve(JobManager);
const logger = container.resolve<Logger>(SERVICES.LOGGER);

const finalStateStatuses: OperationStatus[] = [OperationStatus.COMPLETED, OperationStatus.ABORTED, OperationStatus.EXPIRED];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth to define it in more upper level, even more FINAL states def might be reused in other mapcolonies domain(APP for instance)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, the change should be included in reusing this middle ware below comment on abort logic, finalStatuses will remain in this level as it the middle ware logic that should define it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i reused it below comment

router.get('/parameters', jobsController.getJobByJobsParameters);
router.get('/:jobId', jobsController.getResource);
router.put('/:jobId', jobsController.updateResource);
router.put('/:jobId', validateJobStatusMiddleware, jobsController.updateResource);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not exactly middleware pattern midlleware can come with routes.
Usage should like app.use(validateJobStatusMiddleware(params1, ...));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not accurate, middlewares are also can be defined Route-Level as i did it here, not only Global / Application-Level if you want to it run on specific routes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

throw new NotFoundError(message);
}
if ((jobEntity.status as OperationStatus) === OperationStatus.COMPLETED || (jobEntity.status as OperationStatus) === OperationStatus.ABORTED) {
if (jobEntity.status === OperationStatus.COMPLETED || jobEntity.status === OperationStatus.ABORTED) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here can be used [OperationStatus.COMPLETED, OperationStatus.ABORTED, OperationStatus.EXPIRED] defined previously

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't you put expired here?
How come it wasn't found in the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, reuse the middle ware instead to check job status it inside the function

throw new NotFoundError(message);
}
if ((jobEntity.status as OperationStatus) === OperationStatus.COMPLETED || (jobEntity.status as OperationStatus) === OperationStatus.ABORTED) {
if (jobEntity.status === OperationStatus.COMPLETED || jobEntity.status === OperationStatus.ABORTED) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't you put expired here?
How come it wasn't found in the tests?

Copy link

@alebinson alebinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks GOOOD

@CL-SHLOMIKONCHA CL-SHLOMIKONCHA merged commit ab6a58a into master Feb 24, 2026
8 checks passed
@CL-SHLOMIKONCHA CL-SHLOMIKONCHA deleted the aborted-job-constraint branch February 24, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants